home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 May: Tool Chest / Developer CD Series Tool Chest (Apple Computer)(May 1999).iso / Tool Chest / Development Kits / MPW Related / MPW Script Tips 1.1.1 / Sample Scripts / DeleteMakes < prev    next >
Encoding:
Text File  |  1991-08-16  |  2.4 KB  |  72 lines  |  [TEXT/MPS ]

  1. #-------------------------------------------------------------------------------
  2. #    DeleteMakes
  3. #    MPW Shell Script
  4. #    Written by Gina Cherry • August 16, 1991
  5. #    Copyright:    © 1991 by Apple Computer, Inc., all rights reserved.
  6. #    
  7. #    Usage:
  8. #        DeleteMakes [directory]
  9. #        
  10. #    Function:
  11. #        DeleteMakes generates commands to delete all files named 'Makefile' or ending with '.make'.  DeleteMakes 
  12. #        operates on a directory specified on the command line and all of its subdirectories.  If no directory is 
  13. #        specified, DeleteMakes operates on the current directory.  DeleteMakes generates the delete commands 
  14. #        to a file called DeleteMakes.out, which is opened at the end of this script.  DeleteMakes.out can be executed
  15. #        to delete the Makefiles.
  16. #-------------------------------------------------------------------------------
  17.  
  18. #    Make sure no more than one parameter was specified.
  19.     If {#} > 1
  20.         Echo "### Usage: {0} [directory]"
  21.         Exit 1
  22.     End
  23.  
  24. #    If a parameter was specified, set {dir} to the parameter; otherwise, set {dir} to the  current directory.    
  25.     If {#} == 1
  26.         Set dir "{1}"
  27.     Else
  28.         Set dir `Directory`
  29.     End
  30.  
  31. #    Don't exit on error.    
  32.     Set Exit 0
  33.  
  34. #    If the specified directory does not exist, write error message and exit script.
  35.     If !`Exists -d "{dir}" ≥ Dev:Null`
  36.         Echo "### {0}: Directory {dir} not found"
  37.         Exit 2
  38.     End
  39.     
  40. #    Delete old versions of DeleteMakes.out    
  41.     Close -n {0}.out ≥ Dev:Null
  42.     Delete -y {0}.out ≥ Dev:Null
  43.  
  44. #    Get a list of all directories contained in the specified directory.
  45.     Set directories "`files "{dir}" -r -f -d -o`"
  46. #    Add the specified directory to the beginning of the list of directories.
  47.     Set directories "'{dir}' {directories}"
  48.  
  49. #    Loop through the list of directories.    
  50.     For directory in {directories}
  51.     #    Echo the name of the current directory to the output file.
  52.         Echo "# {directory}" >> {0}.out
  53.         #    Loop through the '.make' files in the current directory, generating a delete command for each.
  54.             For file in `Files -f  -s "{directory}"≈.make` 
  55.                 Echo -n "Delete -y " >> {0}.out
  56.                 Echo "{file}" >>  {0}.out
  57.             End  
  58.         #    Loop through the 'Makefile' files in the current directory, generating a delete command for each.
  59.             For file in `Files -f  -s "{directory}"Makefile ≥ Dev:Null` 
  60.                 Echo -n "Delete -y " >> {0}.out
  61.                 Echo "{file}" >>  {0}.out
  62.             End
  63.         Echo >>  {0}.out
  64.     End ≥ Dev:Null
  65.  
  66. #    Open the output file which contains the delete commands.    
  67.     Open {0}.out
  68.  
  69.  
  70.  
  71.  
  72.